package com.jtjrenren.android.taxi.passenger.core.main;

import com.jtjrenren.android.taxi.passenger.bean.Order;
import com.jtjrenren.android.taxi.passenger.manger.api.ApiWorks;

import com.library.utils.LogUtil;
import com.library.utils.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2016/9/12.
 */

public class MainInteractorImpl implements MainInteractor {
    @Override
    public void getAreaCarList(int carType, String lat, String lng, ApiWorks.ResponseListener listener) {
        ApiWorks.getAreaCarList(lat, lng, carType, listener);
    }

    @Override
    public void ygCost(int type, Order order, ApiWorks.ResponseListener listener) {
        Date date = new Date();
        if (!StringUtils.isEmpty(order.getBookDate())) {
            SimpleDateFormat format = new SimpleDateFormat("yyMMddHHmmss");
            try {
                date = format.parse(order.getBookDate());
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String useTime = simpleDateFormat.format(date);

        LogUtil.log("ordercost", "预估费用：" + "预估时间：" + useTime + "订单信息：" + order.toString());

        ApiWorks.estimateSpecarCost(order.getStartAddr(), order.getStartLat(), order.getStartLng(), order.getEndAddr(), order.getEndLat()
                , order.getEndLng(), type + "", useTime, "", listener);
    }

    @Override
    public void checkNotFinishOrder(String userID, ApiWorks.ResponseListener listener) {
        ApiWorks.checkUserCall(userID, listener);
    }
}
